package keeto.com.vn.bms.network.task;

import java.io.IOException;

import org.apache.http.client.ClientProtocolException;
import org.json.JSONException;

import keeto.com.vn.bms.config.IBMSCore;
import keeto.com.vn.bms.model.User.EditUserModel;
import keeto.com.vn.bms.network.request.EditUserInfoRequest;
import keeto.com.vn.bms.network.response.EditUserInfoResponse;
import keeto.com.vn.bms.utils.BMSListener;

public class TaskEditUserInfo extends AbstractTask{
	
	private EditUserModel userModel;
	private String authKey;

	public TaskEditUserInfo(BMSListener listener, IBMSCore core, EditUserModel model,String AuthKey) {
		super(listener, core);
		// TODO Auto-generated constructor stub
		this.userModel = model;
		this.authKey = AuthKey;
	}

	@Override
	public void run() throws ClientProtocolException, JSONException,
			IOException {
		// TODO Auto-generated method stub
		EditUserInfoRequest request = new EditUserInfoRequest();
		request.setUserModel(userModel);
		request.setAuthKey(authKey);
		EditUserInfoResponse response = protocol.editUserInfo(request);
		for (BMSListener mListener : listener){
			mListener.finishEditUserInfo(response.getReturnCode(), response.getResuiltMsg());
		}
	}

	@Override
	public void timeoutCallback() {
		// TODO Auto-generated method stub
		for (BMSListener mListener : listener){
			mListener.finishEditUserInfo(protocol.STATUS_CODE_GENERIC_FAIL_CONECTTION, null);
		}
	}

}
